package site.marqstree.kotlin.library.good.ui.fragment.category.centent.presenter

import site.marqstree.kotlin.library.base.data.net.observer.RxObserver
import site.marqstree.kotlin.library.base.data.net.request.RxRequest
import site.marqstree.kotlin.library.base.extent.json2List
import site.marqstree.kotlin.library.base.presenter.view.BasePresenter
import site.marqstree.kotlin.library.good.ui.fragment.category.centent.bean.CategoryContentBean
import site.marqstree.kotlin.library.good.ui.fragment.category.centent.view.ContentView
import site.marqstree.kotlin.provider.common.ProviderConstant
import javax.inject.Inject


/*
 * 项目名: KotlinMall
 * 包名: site.marqstree.kotlin.library.good.ui.fragment.category.centent.presenter
 * 文件名: ContentPresenter
 * 创建者: marqstree
 * 创建时间: 2020/3/7 11:58
 * 描述: TODO
 */
class ContentPresenter @Inject constructor():BasePresenter<ContentView>(){

    fun getCategoryContent(categoryId: Int){

        RxRequest.builder()
            .setUrl(ProviderConstant.CATEGORY_CONTENT_URL)
            .setParam("id",categoryId)
            .get()
            .json2List(CategoryContentBean::class.java)
            .subscribe(object :RxObserver<List<CategoryContentBean>>(){
                override fun onNext(data: List<CategoryContentBean>) {
                    mView.onContentResult(data)
                }
            })
    }

}